package com.padakeji.android.pworks.module.nav.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.View;
import com.padakeji.android.pworks.module.nav.bean.NavItem;
import java.util.Arrays;
import java.util.List;

/**
 * Created by AtanL on 2015/9/23.
 */
public class ViewNavPagerAdapter extends FragmentPagerAdapter {

    private Context mContext;
    private List<NavItem> navItems;

    public ViewNavPagerAdapter(@NonNull FragmentManager fm, @NonNull Context context, @NonNull NavItem[] items) {
        super(fm);
        this.mContext = context;
        navItems = Arrays.asList(items);
    }

    @Override
    public Fragment getItem(int position) {
        return navItems.get(position).fragment;
    }

    @Override
    public int getCount() {
        return navItems.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return navItems.get(position).title;
    }

    public View getPageTabView(int position) {
        return navItems.get(position).tabView;
    }

}
